package com.baohulu.baohulu.activity.userprofile;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.widget.TextView;

import com.baohulu.baohulu.R;
import com.baohulu.baohulu.common.Const;
import com.baohulu.baohulu.utils.SharedPrefUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class UserProfileActivity extends AppCompatActivity {

    @BindView(R.id.nick_name)
    TextView mTvNickname;
    @BindView(R.id.tv_bold_nick_name)
    TextView mTvBoldNickname;
    @BindView(R.id.phone_number)
    TextView mTvPhoneNumber;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_edit_profile);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.ll_nick_name)
    public void updateNickName() {
        Intent intent = new Intent(this, UpdateNickNameActivity.class);
        startActivity(intent);
    }

    @OnClick(R.id.ll_phone_number)
    public void updatePhoneNumber() {
        //pass

    }

    @OnClick(R.id.ll_wechat)
    public void bindWechat() {
        //pass
    }

    @OnClick(R.id.ll_update_password)
    public void updatePassword() {
        startActivity(new Intent(this, UpdatePasswordActivity.class));
    }


    @Override
    protected void onResume() {
        super.onResume();
        showNickname();
        showPhoneNumber();
    }

    private void showPhoneNumber() {
        String phoneNumber = SharedPrefUtil.getString(Const.SpKey.LOGIN_USER_ACCOUNT);
        if (!TextUtils.isEmpty(phoneNumber)) {
            String displayPhoneNumber = phoneNumber.substring(0, 3) + "****" + phoneNumber.substring(7);
            mTvPhoneNumber.setText(displayPhoneNumber);
        }
    }

    private void showNickname() {
        String nickname = SharedPrefUtil.getString(Const.SpKey.LOGIN_USER_NICKNAME);
        mTvNickname.setText(nickname);
        mTvBoldNickname.setText(nickname);
    }
}
